from common.mysql_operate import db
from model.User import User


class UserStore():
    def save(self, user):
        sql = user.generate_insert_sql()
        print(sql)
        db.execute_db(sql)

    def list(self):
        return db.select_db(User.generate_list_sql())

    def find_by_name(self, name):
        return db.select_db(User.generate_find_by_name_sql(name))

    def delete_by_name(self, name):
        db.execute_db(User.generate_delete_by_name_sql(name))

    def update_by_name(self, user):
        db.execute_db(user.generate_update_sql())
